From 09b0652c8f1eb0664b1d1e9c98c6473ffa14babe Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Mon, 21 Aug 2006 10:28:02 +0100 Subject: [PATCH] [XEN] Fix shadow2 integration with writable-pagetable logic. Signed-off-by: Keir Fraser --- xen/arch/x86/mm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 7ec237ee8b..2c42f05ee9 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3139,13 +3139,14 @@ static int ptwr_emulated_update( } } - /* Checked successfully: do the update (write or cmpxchg). */ pl1e = map_domain_page(page_to_mfn(page)); pl1e = (l1_pgentry_t *)((unsigned long)pl1e + (addr & ~PAGE_MASK)); + + if ( shadow2_mode_enabled(d) ) + shadow2_lock(d); + if ( do_cmpxchg ) { - if ( shadow2_mode_enabled(d) ) - shadow2_lock(d); ol1e = l1e_from_intpte(old); if ( cmpxchg((intpte_t *)pl1e, old, val) != old ) { @@ -3155,11 +3156,6 @@ static int ptwr_emulated_update( put_page_from_l1e(nl1e, d); return X86EMUL_CMPXCHG_FAILED; } - if ( unlikely(shadow2_mode_enabled(v->domain)) ) - { - shadow2_validate_guest_entry(v, _mfn(page_to_mfn(page)), pl1e); - shadow2_unlock(v->domain); - } } else { @@ -3168,6 +3164,12 @@ static int ptwr_emulated_update( BUG(); } + if ( shadow2_mode_enabled(d) ) + { + shadow2_validate_guest_entry(v, _mfn(page_to_mfn(page)), pl1e); + shadow2_unlock(v->domain); + } + unmap_domain_page(pl1e); /* Finally, drop the old PTE. */ -- 2.30.2